<?php

namespace App\Http\Controllers\Api\V1;

use App\Models\Complain;
use App\Models\MatchOrder;
use App\Models\Traits\UploadsHelper;
use Dingo\Api\Exception\ResourceException;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Storage;

class ComplainController extends Controller
{
    use UploadsHelper;
    public function store(Request $request)
    {

        // 当前用户这一单是入金还是提现
        $dataArr = $request->only(['match_order_id','reason','type','image_url']);
        $matchOrder = MatchOrder::where('id',$dataArr['match_order_id'])->first();
        if($matchOrder->is_cancle) {
            throw new ResourceException('error',[['error_code'=>'430005','message'=>'取消订单不可以申诉！']]);
        }
        if($matchOrder->type == 'deposit') {

        }
        //上传的头像字段avatar是文件类型
        $dataArr['image_url'] = $this->avatarCompile();//就是很简单的一个步骤

        $res = Complain::create($dataArr);
        return $res;

    }
    // is_cancle 是否取消订单 取消订单不可以申诉

    // 入金用户 匹配订单时间超过3小时 并且 提现的人没有确认

    // 入金用户 匹配订单时间超过3小时 并且 提现的人没有确认




}
